var http = require('http');
var o1 = {
	orderIds: ["078HD383PU5T1SYFO284JQVGD",
		"2H5BWOCO5PTLJKUN75YH8CNEA"
	]
}
var o2 = ["078HD383PU5T1SYFO284JQVGD",
	"2H5BWOCO5PTLJKUN75YH8CNEA"
]
var postData;
var parse = require('url-parse')
var lodash = require('lodash');
postData = JSON.stringify(o1);

function fetchApi(opts) {
	return new Promise(function(resolve, reject) {
		var req = http.request(opts, (res) => {
			res.setEncoding('utf8');
			res.on('data', (chunk) => {
				console.log(`BODY: ${chunk}`);
			});
			res.on('end', () => {
				console.log('No more data in response.')
			});
			res.on('error', (err) => {
				console.log(err)
			})
		});

		req.on('error', (e) => {
			console.log(`problem with request: ${e.message}`);
		});

		// write data to request body
		req.write(postData);
		req.end();
	});
}

var opts = {
	hostname: '172.16.255.133',
	port: 3000,
	path: '/order/getOrderByIds/',
	method: 'POST',
	headers: {
		// 'Content-Type': 'application/x-www-form-urlencoded',
		'Content-Type': 'text/plain',
		'Content-Length': Buffer.byteLength(postData)
	}
};

module.exports = function() {
	debugger
	fetchApi(opts);
}
